package com.captainbank.tcl.tclapplication.ui.activity.function;

import android.animation.Animator;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.captainbank.tcl.tclapplication.R;
import com.captainbank.tcl.tclapplication.ui.activity.basic.BaseActivity;
import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by TCL on 2019/6/17.
 * Describe:
 */
public class AnimationsViewActivity extends BaseActivity {
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.tv_show)
    TextView tvShow;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_animations_view;
    }

    @Override
    protected void initView() {
        toolbar.setTitle(getString(R.string.title_animations_view));
    }

    @OnClick({R.id.btn1, R.id.btn2, R.id.btn3, R.id.btn4, R.id.btn5, R.id.btn6, R.id.btn7, R.id.btn8,
            R.id.btn9, R.id.btn10, R.id.btn11, R.id.btn12, R.id.btn13, R.id.btn14, R.id.btn15, R.id.btn16})
    public void onViewClicked(View view) {
        Techniques techniques;
        switch (view.getId()) {
            case R.id.btn1:
            default:
                techniques=Techniques.Flash;
                break;
            case R.id.btn2:
                techniques=Techniques.Pulse;
                break;
            case R.id.btn3:
                techniques=Techniques.Hinge;
                break;
            case R.id.btn4:
                techniques=Techniques.RollIn;
                break;
            case R.id.btn5:
                techniques=Techniques.BounceIn;
                break;
            case R.id.btn6:
                techniques=Techniques.BounceInDown;
                break;
            case R.id.btn7:
                techniques=Techniques.FadeIn;
                break;
            case R.id.btn8:
                techniques=Techniques.FadeInUp;
                break;
            case R.id.btn9:
                techniques=Techniques.FlipInX;
                break;
            case R.id.btn10:
                techniques=Techniques.FlipOutX;
                break;
            case R.id.btn11:
                techniques=Techniques.RotateIn;
                break;
            case R.id.btn12:
                techniques=Techniques.RotateInDownLeft;
                break;
            case R.id.btn13:
                techniques=Techniques.SlideInLeft;
                break;
            case R.id.btn14:
                techniques=Techniques.SlideInRight;
                break;
            case R.id.btn15:
                techniques = Techniques.ZoomIn;
                break;
            case R.id.btn16:
                techniques = Techniques.ZoomInDown;
                break;

        }
        startAnimations(techniques);
    }

    private void startAnimations(Techniques techniques) {
        YoYo.with(techniques)
                .onEnd(new YoYo.AnimatorCallback() {
                    @Override
                    public void call(Animator animator) {

                    }
                })
                .duration(500)
                .repeat(3)
                .playOn(tvShow);
    }
}
